<?php
define('IN_ECS', true);
require('../includes/init.php');
//include_once('fmconfig.php');

$menuid = isset($_REQUEST['mid'])?$_REQUEST['mid']:'';

if($menuid == ''){
    echo '<root><error>Please input menu id.</error></root>';
    exit;
}

$fmuid = $_SESSION['user_id'];

//一级分类，主分类下的子项。
$sql = "select * from ".$ecs->table('category')." where parent_id = ".$menuid;
$row = $GLOBALS['db']->getAll($sql);
$menu = '';
foreach($row as $d){
    $menu .= "<item label='".$d['cat_name']."'>";
    //二级分类*/
    $sql2 = "select a.* from ".$ecs->table('goods')." as a  where a.cat_id=".$d['cat_id'];
    $row1 = $GLOBALS['db']->getAll($sql2);
    //echo var_dump($data1);
    if(count($row1)>0){
        foreach($row1 as $d1){
            $menu .= "<item id='".$d1['goods_id']."' label='".$d1['goods_name']."' data='".$d1['goods_sn']."' />";
        }
    }
    $menu .= "</item>";
}
$info = "<root>".$menu."</root>";
echo $info;
?>